// source --> https://www.serisign.com/wp-content/plugins/wp-google-map-pro/js/wpgmp-google-map.js?ver=5.7.11 jQuery(document).ready(function($) { jQuery(".wpgmp_search_input").keyup(function(){ map_id=$(this).attr("rel"); jQuery(".wpgmp_locations_listing[rel='"+map_id+"']").addClass("wpgmp_loading"); wpgmp_filter_locations(map_id,1); }); jQuery(".wpgmp-tab-2").click(function() { map_id=$(this).attr("rel"); jQuery(".wpgmp-tab-1[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-3[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-4[rel='"+map_id+"']").removeClass("active"); jQuery(this).addClass("active"); jQuery("#wpgmp_cat_tab"+map_id+"").hide(); jQuery("#wpgmp_nearby_tab"+map_id+"").hide(); jQuery("#wpgmp_route_tab"+map_id+"").hide(); jQuery("#wpgmp_dir_tab"+map_id+"").show(); }); jQuery(".wpgmp-tab-1").click(function() { map_id=$(this).attr("rel"); jQuery(".wpgmp-tab-2[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-3[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-4[rel='"+map_id+"']").removeClass("active"); jQuery(this).addClass("active"); jQuery("#wpgmp_dir_tab"+map_id+"").hide(); jQuery("#wpgmp_nearby_tab"+map_id+"").hide(); jQuery("#wpgmp_route_tab"+map_id+"").hide(); jQuery("#wpgmp_cat_tab"+map_id+"").show(); }); jQuery(".wpgmp-tab-3").click(function() { map_id=$(this).attr("rel"); jQuery(".wpgmp-tab-1[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-2[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-4[rel='"+map_id+"']").removeClass("active"); jQuery(this).addClass("active"); jQuery("#wpgmp_cat_tab"+map_id+"").hide(); jQuery("#wpgmp_dir_tab"+map_id+"").hide(); jQuery("#wpgmp_route_tab"+map_id+"").hide(); jQuery("#wpgmp_nearby_tab"+map_id+"").show(); }); jQuery(".wpgmp-tab-4").click(function() { map_id=$(this).attr("rel"); jQuery(".wpgmp-tab-1[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-2[rel='"+map_id+"']").removeClass("active"); jQuery(".wpgmp-tab-3[rel='"+map_id+"']").removeClass("active"); jQuery(this).addClass("active"); jQuery("#wpgmp_cat_tab"+map_id+"").hide(); jQuery("#wpgmp_dir_tab"+map_id+"").hide(); jQuery("#wpgmp_nearby_tab"+map_id+"").hide(); jQuery("#wpgmp_route_tab"+map_id+"").show(); }); jQuery(".wpgmp_mcurrent_loction").click(function() { wpgmp_get_current_location(); }); jQuery(".wpgmp_ecurrent_loction").click(function() { wpgmp_get_ecurrent_location(); }); }); function wpgmp_get_current_location() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(wpgmp_success, wpgmp_error); } else { alert("Geolocation not supported. Please check your location permissions"); } } function wpgmp_success(position) { myLat = position.coords.latitude; myLng = position.coords.longitude; var mylatlng = new google.maps.LatLng(myLat, myLng); var geocoder = new google.maps.Geocoder(); geocoder.geocode({"latLng": mylatlng}, function(results, status) { if(status == google.maps.GeocoderStatus.OK) { current_address = results[0]["formatted_address"]; jQuery(".wpgmp_set_current_location").html(current_address); jQuery(".fromloc").val(current_address); }; }); } function wpgmp_get_ecurrent_location() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(wpgmp_esuccess, wpgmp_error); } else { alert("Geolocation not supported. Please check your location permissions"); } } function wpgmp_esuccess(position) { myLat = position.coords.latitude; myLng = position.coords.longitude; var mylatlng = new google.maps.LatLng(myLat, myLng); var geocoder = new google.maps.Geocoder(); geocoder.geocode({"latLng": mylatlng}, function(results, status) { if(status == google.maps.GeocoderStatus.OK) { current_address = results[0]["formatted_address"]; jQuery(".wpgmp_set_current_location").html(current_address); jQuery(".toloc").val(current_address); }; }); } function wpgmp_error(msg) { alert("Geolocation not supported. Please check your location permissions"); } function wpgmp_filter_nearby_locations(map_id,location_ids) { if(location_ids=="") location_ids=0; var data = { action: "wpgmp_get_map_location", map_id: map_id, location_ids: location_ids }; jQuery.post(wpgmp_ajaxurl.ajaxurl, data, function(response) { jQuery("#wpgmp_locations_listing"+map_id).html(response); jQuery("#wpgmp_locations_listing"+map_id).removeClass("wpgmp_loading"); }); } function wpgmp_filter_locations(map_id,page) { var filter_category = ""; search_term=jQuery(".wpgmp_search_input[rel='"+map_id+"']").val(); map_id=jQuery("#wpgmp_locations_listing"+map_id).attr('rel'); //get checked categories here all_checked=jQuery(".wpgmp_specific_category_location:checkbox:checked"); if(all_checked.length!=0) { var selected_categories=new Array(); jQuery(all_checked).each(function(){ selected_categories.push(this.value); }); filter_category=selected_categories.join(","); } var data = { action: "wpgmp_get_map_location", map_id: map_id, search_text: search_term, filter_category:filter_category, page : page }; jQuery.post(wpgmp_ajaxurl.ajaxurl, data, function(response) { jQuery("#wpgmp_locations_listing"+map_id).html(response); jQuery("#wpgmp_locations_listing"+map_id).removeClass("wpgmp_loading"); }); } function wpgmp_sort_distance(obj) { var arr = []; for (var prop in obj) { if (obj.hasOwnProperty(prop)) { arr.push({ "key": prop, "value": obj[prop] }); } } arr.sort(function(a, b) { return a.value - b.value; }); //arr.sort(function(a, b) { a.value.toLowerCase().localeCompare(b.value.toLowerCase()); }); //use this to sort as strings return arr; // returns array } function wpgmp_nearby_locations(markers,map_id,map_div_id) { radius=jQuery("#wpgmp_radius"+map_id).val(); navigator.geolocation.getCurrentPosition(function(position) { var lat1 = position.coords.latitude; var lon1 = position.coords.longitude; var location_ids=new Array(); var near_locations="
"+ ""; jQuery("#locations-panel"+map_id).html(near_locations).show(); location_ids=location_ids.join(","); wpgmp_filter_nearby_locations(map_id,location_ids); }); } function wpgmp_get_nearby_locations(markers,lat1,lon1,radius,div_id) { var radius_km = 6371; max_radius_km=radius*1.61; var distances = []; var closest = -1; var pi = Math.PI; var marker_info = {}; for( i=0;i